package cn.edu.nwsuaf.examcenter.controller;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.edu.nwsuaf.examcenter.service.ExerciceItemService;

@Controller
@RequestMapping(value="/exerciceItem")
public class ExerciceItemController {

	@Resource(name="exerciceItemService")
	private ExerciceItemService exerciceItemService;
	
	@RequestMapping(value="/loadExerciceItem")
	public String loadExerciceItem(@RequestParam(value="key",required=false)String key, @RequestParam(value="p",required=false)String p, ModelMap modelMap){
		exerciceItemService.loadExerciceItem(modelMap);
		
		return "exam/exercice-item-list";
	}
	
	@ResponseBody
	@RequestMapping(value="/json/deleteExerciceItem/{itemNo}")
	public String jsonDeleteExerciceItem(@PathVariable String itemNo){
		exerciceItemService.deleteExerciceItem(itemNo);
		return "success";
	}
	
	@RequestMapping(value="/showExerciceItem/{itemNo}")
	public String showExerciceItem(@PathVariable String itemNo, ModelMap modelMap){
		exerciceItemService.showItemInfo(itemNo, modelMap);
		
		return "exam/exercice-item-show";
	}
}
